/*    */ package com.zimbra.cs.service.admin;
/*    */ 
/*    */ import com.zimbra.common.account.Key.DomainBy;
/*    */ import com.zimbra.common.account.Key.ServerBy;
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.AdminConstants;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.cs.account.Domain;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import com.zimbra.cs.account.Server;
/*    */ import com.zimbra.cs.account.XMPPComponent;
/*    */ import com.zimbra.cs.account.accesscontrol.AdminRight;
/*    */ import com.zimbra.cs.account.accesscontrol.Rights.Admin;
/*    */ import com.zimbra.cs.account.accesscontrol.TargetType;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class CreateXMPPComponent
/*    */   extends AdminDocumentHandler
/*    */ {
/*    */   public Element handle(Element request, Map<String, Object> context)
/*    */     throws ServiceException
/*    */   {
/* 47 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/* 48 */     Provisioning prov = Provisioning.getInstance();
/*    */     
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/* 60 */     Element cEl = request.getElement("xmppcomponent");
/* 61 */     Map<String, Object> attrs = AdminService.getAttrs(cEl);
/*    */     
/* 63 */     Element domainElt = cEl.getElement("domain");
/* 64 */     String byStr = domainElt.getAttribute("by", "id");
/* 65 */     Key.DomainBy domainby = Key.DomainBy.valueOf(byStr);
/* 66 */     Domain domain = Provisioning.getInstance().get(domainby, domainElt.getText());
/*    */     
/* 68 */     Element serverElt = cEl.getElement("server");
/* 69 */     String serverByStr = serverElt.getAttribute("by");
/* 70 */     Server server = prov.get(Key.ServerBy.fromString(serverByStr), serverElt.getText());
/*    */     
/* 72 */     String name = cEl.getAttribute("name");
/*    */     
/* 74 */     if (!name.endsWith(domain.getName())) {
/* 75 */       throw ServiceException.INVALID_REQUEST("Specified component name must be full name, and must be a subdomain of the specified parent", null);
/*    */     }
/*    */     
/* 78 */     checkRight(zsc, context, null, Rights.Admin.R_createXMPPComponent);
/* 79 */     checkSetAttrsOnCreate(zsc, TargetType.xmppcomponent, name, attrs);
/*    */     
/* 81 */     XMPPComponent comp = prov.createXMPPComponent(name, domain, server, attrs);
/*    */     
/* 83 */     Element response = zsc.createElement(AdminConstants.CREATE_XMPPCOMPONENT_RESPONSE);
/* 84 */     GetXMPPComponent.encodeXMPPComponent(response, comp);
/* 85 */     return response;
/*    */   }
/*    */   
/*    */   public void docRights(List<AdminRight> relatedRights, List<String> notes)
/*    */   {
/* 90 */     relatedRights.add(Rights.Admin.R_createXMPPComponent);
/* 91 */     notes.add(String.format("All attrs provided in the attribute list have to settable by. the authed admin.   You can grant the %s right, which allows setting all attributes on %s, or grant the set attrs right just for the attributes the admin needs to set while creating an entry.", new Object[] { Rights.Admin.R_modifyXMPPComponent.getName(), "XMPP component" }));
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/admin/CreateXMPPComponent.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */